/*
@author https://yunp.top
 */

@file:JsQualifier("openfl.display")

package openfl.display

import openfl.display3D.textures.TextureBase
import openfl.filters.BitmapFilter
import openfl.geom.Point
import openfl.geom.Rectangle
import openfl.utils.Future
import org.w3c.dom.HTMLCanvasElement

open external class BitmapData(
    width: Int,
    height: Int,
    transparent: Boolean = definedExternally,
    fillColor: Long = definedExternally
) {
    companion object {
        fun fromCanvas(canvas: HTMLCanvasElement, transparent: Boolean = definedExternally): BitmapData
        fun fromTexture(texture: TextureBase): BitmapData
        fun loadFromBase64(base64: String, type: String): Future<BitmapData>
        fun loadFromBytes(bytes: openfl.utils.ByteArray, rawAlpha: ByteArray = definedExternally): Future<BitmapData>
        fun loadFromFile(path: String): Future<BitmapData>
    }

    val height: Int
    val rect: Rectangle
    val transparent: Boolean
    val width: Int

    fun applyFilter(sourceBitmapData: BitmapData, sourceRect: Rectangle, destPoint: Point, filter: BitmapFilter)
    fun clone(): BitmapData

}